//
//  WUMessageViewController.m
//  Home
//
//  Created by 吴军虎吴军虎 on 16/5/3.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "WUMessageViewController.h"
#import "WUMessageTableViewCell.h"
#import "TongViewController.h"

@interface WUMessageViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray *imageArray;
}
@property (nonatomic,retain) UITableView *tableView;
@property(nonatomic,retain)UIView *headerView;
@property (nonatomic,retain) UIImageView *touImage;
@property (nonatomic,retain) UIImageView *xiaoImage;
@property (nonatomic,retain) UIImageView *xiaoImage1;
@property (nonatomic,retain) UIImageView *xiaoImage2;
@property (nonatomic,retain) UILabel *renlabel;

@end

@implementation WUMessageViewController

-(void) viewWillAppear:(BOOL)animated
{

    self.title=@"消息";
    self.tabBarController.tabBar.hidden=NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    imageArray=[NSArray arrayWithObjects:[UIImage imageNamed:@"ni"],[UIImage imageNamed:@"nn"],[UIImage imageNamed:@"wo"],[UIImage imageNamed:@"ww"],[UIImage imageNamed:@"to"],[UIImage imageNamed:@"tt"],[UIImage imageNamed:@"yo"],[UIImage imageNamed:@"yy"], nil];
    
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-66 *AUTO_HEIGHT) style:UITableViewStylePlain];
    _tableView.separatorStyle=UITableViewCellSelectionStyleNone;
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.backgroundColor=LV;
    [self.view addSubview:_tableView];
    
    _headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 217/2 *AUTO_WIDTH)];
    _headerView.backgroundColor=LV;
    _headerView.layer.masksToBounds=YES;
    _headerView.userInteractionEnabled=YES;
    _tableView.tableHeaderView=_headerView;
    
    UIView *baiView=[[UIView alloc]init];
    baiView.backgroundColor=[UIColor whiteColor];
    baiView.layer.masksToBounds=YES;
    baiView.userInteractionEnabled=YES;
    UITapGestureRecognizer *batap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(baAction:)];
    [baiView addGestureRecognizer:batap];
    [_headerView addSubview:baiView];
    [baiView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_headerView).offset(50/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 117/2 *AUTO_WIDTH));
    }];
    
    
    _touImage=[[UIImageView alloc]init];
    _touImage.image=[UIImage imageNamed:@"headBackImage"];
    _touImage.layer.masksToBounds=YES;
    _touImage.layer.cornerRadius=90/4;
    [baiView addSubview:_touImage];
    [_touImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(baiView).offset(15/2 *AUTO_WIDTH);
        make.left.equalTo(baiView).offset(22/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(90/2 *AUTO_WIDTH, 90/2 *AUTO_WIDTH));
    }];
    
    
    UILabel *tonglabel=[[UILabel alloc]init];
    tonglabel.text=@"通知";
    tonglabel.alpha=0.6;
    tonglabel.font=[UIFont systemFontOfSize:14];
    [baiView addSubview:tonglabel];
    [tonglabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(baiView).offset(28/2 *AUTO_WIDTH);
        make.left.equalTo(_touImage.mas_right).offset(29/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(100 *AUTO_WIDTH, 15 *AUTO_WIDTH));
    }];
    
    
    _renlabel=[[UILabel alloc]init];
    _renlabel.text=@"暂无任何通知";
    _renlabel.alpha=0.6;
    _renlabel.font=[UIFont systemFontOfSize:12];
    [baiView addSubview:_renlabel];
    [_renlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(tonglabel.mas_bottom).offset(15/2 *AUTO_WIDTH);
        make.left.equalTo(_touImage.mas_right).offset(29/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(_renlabel.text.length *15 *AUTO_WIDTH, 11 *AUTO_WIDTH));
    }];
    
    
    //绿色图片
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(310.00*AUTO_WIDTH, 15.00*AUTO_WIDTH, 40.00*AUTO_WIDTH, 40.00*AUTO_WIDTH)];
    imageView.image = [UIImage imageNamed:@"jiantou"];
    [baiView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(baiView);
        make.right.mas_equalTo(-21.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(18.00*AUTO_WIDTH, 18.00*AUTO_WIDTH));
        
    }];

    _xiaoImage=[[UIImageView alloc]init];
    _xiaoImage.image=[UIImage imageNamed:@"ni"];
    _xiaoImage.layer.masksToBounds=YES;
    _xiaoImage.layer.cornerRadius=70/4;
    [baiView addSubview:_xiaoImage];
    [_xiaoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(baiView).offset(25/2 *AUTO_WIDTH);
        make.right.equalTo(imageView.mas_right).offset(-40/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(70/2 *AUTO_WIDTH, 70/2 *AUTO_WIDTH));
    }];
    
    
    _xiaoImage1=[[UIImageView alloc]init];
    _xiaoImage1.image=[UIImage imageNamed:@"nn"];
    _xiaoImage1.layer.masksToBounds=YES;
    _xiaoImage1.layer.cornerRadius=70/4;
    [baiView addSubview:_xiaoImage1];
    [_xiaoImage1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(baiView).offset(25/2 *AUTO_WIDTH);
        make.right.equalTo(imageView.mas_right).offset(-70/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(70/2 *AUTO_WIDTH, 70/2 *AUTO_WIDTH));
    }];
    
    
    
    _xiaoImage2=[[UIImageView alloc]init];
    _xiaoImage2.image=[UIImage imageNamed:@"wo"];
    _xiaoImage2.layer.masksToBounds=YES;
    _xiaoImage2.layer.cornerRadius=70/4;
    [baiView addSubview:_xiaoImage2];
    [_xiaoImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(baiView).offset(25/2 *AUTO_WIDTH);
        make.right.equalTo(imageView.mas_right).offset(-100/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(70/2 *AUTO_WIDTH, 70/2 *AUTO_WIDTH));
    }];
    
    UILabel *lianlabel=[[UILabel alloc]init];
    lianlabel.text=@"最近联系人";
    lianlabel.alpha=0.6;
    lianlabel.font=[UIFont systemFontOfSize:12];
    [_headerView addSubview:lianlabel];
    [lianlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(baiView.mas_bottom).offset(0);
        make.left.equalTo(self.view).offset(30/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(_renlabel.text.length *11 * AUTO_WIDTH, 50/2 *AUTO_WIDTH));
    }];

}

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 8;
}

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 136/2 *AUTO_WIDTH;
}


-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellIdentifer=@"cell";
    
   
    WUMessageTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    
    if (cell==nil) {
        
        cell=[[WUMessageTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifer];
        
        
        if (indexPath.row == 7) {
            cell.henglabel.alpha = 0;
        }
    }
    
    
    
    
    cell.touImage.image=[imageArray objectAtIndex:indexPath.row];
    
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"按钮被点击了");
}

-(void) baAction:(UITapGestureRecognizer *) tap
{
    TongViewController *tong=[[TongViewController alloc]init];
    [self.navigationController pushViewController:tong animated:YES];
    NSLog(@"点击按钮了");
}

@end
